{}展开

[modao@modao shell_snippet]$ echo {hello, world}
{hello, world}
[modao@modao shell_snippet]$ echo {hello,world}
hello world

判断字符串是否包含子串

# 通过 ** 匹配
if [[ "${var}" == *"${sub_string}"* ]]; then
    printf '%s\n' "sub_string is in var."
fi

# 通过 bash 内置的 =~ 判断
if [[ "${sub_string}" =~ "${var}" ]]; then
    printf '%s\n' "sub_string is in var."
fi

来自: + 搬砖常用的 shell 片段记录 + 有趣的Shell Snippet